package com.hong.concurrent.chapter18;

/**
 * @Author csh
 * @Description
 * @Date 2018/7/12 22:09
 */
public class MakerClientThread extends Thread {

    private final ActiveObject activeObject;
    private final char fillChar;

    public MakerClientThread(ActiveObject activeObject, String name) {
        super(name);
        this.activeObject = activeObject;
        this.fillChar = name.charAt(0);
    }

    @Override
    public void run() {
        try {
            for (int i =0;true;i++){
                Result result = activeObject.makeString(i + 1, fillChar);
                Thread.sleep(20);
                String resultValue = (String) result.getResultValue();
                System.out.println(Thread.currentThread().getName()+": value="+resultValue);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
